package org.htmlparser.parserapplications.filterbuilder.wrappers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.filters.HasSiblingFilter;
import org.htmlparser.parserapplications.filterbuilder.Filter;
import org.htmlparser.parserapplications.filterbuilder.SubFilterList;

public class HasSiblingFilterWrapper extends Filter
  implements ActionListener
{
  protected SubFilterList mContainer;
  protected HasSiblingFilter mFilter = new HasSiblingFilter();

  public HasSiblingFilterWrapper()
  {
    this.mContainer = new SubFilterList(this, "Sibling Filter", 1);
    add(this.mContainer);
  }

  public boolean accept(Node paramNode)
  {
    return this.mFilter.accept(paramNode);
  }

  public void actionPerformed(ActionEvent paramActionEvent)
  {
  }

  public String getDescription()
  {
    return "Has Sibling";
  }

  public String getIconSpec()
  {
    return "images/HasSiblingFilter.gif";
  }

  public NodeFilter getNodeFilter()
  {
    HasSiblingFilter localHasSiblingFilter = new HasSiblingFilter();
    NodeFilter localNodeFilter = this.mFilter.getSiblingFilter();
    if (localNodeFilter != null)
      localHasSiblingFilter.setSiblingFilter(((Filter)localNodeFilter).getNodeFilter());
    return localHasSiblingFilter;
  }

  public NodeFilter[] getSubNodeFilters()
  {
    NodeFilter[] arrayOfNodeFilter;
    NodeFilter localNodeFilter = this.mFilter.getSiblingFilter();
    if (localNodeFilter != null)
    {
      arrayOfNodeFilter = new NodeFilter[1];
      arrayOfNodeFilter[0] = localNodeFilter;
    }
    while (true)
    {
      return arrayOfNodeFilter;
      arrayOfNodeFilter = new NodeFilter[0];
    }
  }

  public void setNodeFilter(NodeFilter paramNodeFilter, Parser paramParser)
  {
    this.mFilter = ((HasSiblingFilter)paramNodeFilter);
  }

  public void setSubNodeFilters(NodeFilter[] paramArrayOfNodeFilter)
  {
    if (paramArrayOfNodeFilter.length != 0)
      this.mFilter.setSiblingFilter(paramArrayOfNodeFilter[0]);
    while (true)
    {
      return;
      this.mFilter.setSiblingFilter(null);
    }
  }

  public String toJavaCode(StringBuffer paramStringBuffer, int[] paramArrayOfInt)
  {
    String str1;
    if (this.mFilter.getSiblingFilter() != null)
      str1 = ((Filter)this.mFilter.getSiblingFilter()).toJavaCode(paramStringBuffer, paramArrayOfInt);
    while (true)
    {
      StringBuffer localStringBuffer = new StringBuffer().append("filter");
      int i = paramArrayOfInt[1];
      paramArrayOfInt[1] = (i + 1);
      String str2 = i;
      spaces(paramStringBuffer, paramArrayOfInt[0]);
      paramStringBuffer.append("HasSiblingFilter ");
      paramStringBuffer.append(str2);
      paramStringBuffer.append(" = new HasSiblingFilter ();");
      newline(paramStringBuffer);
      if (str1 != null)
      {
        spaces(paramStringBuffer, paramArrayOfInt[0]);
        paramStringBuffer.append(str2);
        paramStringBuffer.append(".setSiblingFilter (");
        paramStringBuffer.append(str1);
        paramStringBuffer.append(");");
        newline(paramStringBuffer);
      }
      return str2;
      str1 = null;
    }
  }
}